
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Zookeeper的核心架构有哪些组件？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Zookeeper的核心架构有哪些组件？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">角色</div>
          <div class="card-question">在Zookeeper集群中，Leader节点的核心职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">角色</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Leader是唯一一个负责处理所有写请求的节点。它的主要功能包括：处理客户端写请求、发起并管理ZAB协议以确保数据顺序一致性、确保所有节点数据同步、以及协调集群内的节点状态和管理会话。</div>
          </div>
          <div class="card-source">来源: 1. Leader（领导者）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">角色</div>
          <div class="card-question">Follower节点在Zookeeper集群中扮演了哪些角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">角色</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Follower是集群中的从节点，主要功能包括：处理客户端的读请求、接受并应用Leader发送的写提案以保持数据同步、在当前Leader失效时参与新Leader的选举，并监控Leader的健康状态。</div>
          </div>
          <div class="card-source">来源: 2. Follower（跟随者）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Zookeeper中的Observer节点与Follower节点有何主要区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要区别在于Observer不参与写请求的投票。虽然Observer和Follower都能处理读请求并同步Leader的状态，但Observer不投票的特性旨在增加系统的读取扩展性，同时不影响写操作的性能。</div>
          </div>
          <div class="card-source">来源: 3. Observer（观察者）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">概念</div>
          <div class="card-question">什么是Znode？它支持哪些不同类型的节点以适应不同场景？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">概念</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Znode是Zookeeper的核心数据结构，类似于文件系统中的节点，所有数据都存储在Znode中。它支持临时节点（Ephemeral）、持久节点（Persistent）和有序节点（Sequential）以适应不同的使用场景。</div>
          </div>
          <div class="card-source">来源: 5. Znode（数据节点）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">架构</div>
          <div class="card-question">Zookeeper集群（Ensemble）存在的主要目的是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">架构</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper集群的主要目的是实现高可用性和数据的强一致性。它通过多个节点提供可靠的分布式协调服务，确保即使在个别节点故障的情况下，服务依然可用，并且集群中的所有节点都有相同的数据副本。</div>
          </div>
          <div class="card-source">来源: 6. Zookeeper Ensemble（集群）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Zookeeper使用哪两种机制来保证数据的持久化和快速恢复？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zookeeper使用事务日志（Transaction Log）和快照（Snapshot）来保证持久化和恢复。日志记录了每个写请求，用于在节点宕机后恢复状态；快照则定期将内存数据保存到磁盘，以加快恢复速度。</div>
          </div>
          <div class="card-source">来源: 7. 日志（Transaction Log）和快照（Snapshot）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Zookeeper中，读请求和写请求是如何被不同角色的节点处理的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">写请求必须被发送到Leader节点进行处理。而读请求可以由Follower或Observer节点直接处理，因为在任何一个节点上读操作都是一致的。</div>
          </div>
          <div class="card-source">来源: 1. Leader（领导者）, 2. Follower（跟随者）, 4. Client（客户端）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">客户端（Client）如何通过Watcher机制与Zookeeper进行交互？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">客户端可以设置Watcher来监听Znode的数据变化或状态变化。当被监听的Znode发生变化时，Zookeeper会向客户端发送通知，从而实现一种高效的通知机制。</div>
          </div>
          <div class="card-source">来源: 4. Client（客户端）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当Zookeeper集群的Leader节点失效时，会发生什么？哪些节点会参与后续过程？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当Leader失效时，Follower节点会发现其健康状态出现问题，并触发新Leader的选举过程。Follower节点会参与投票，选举出新的Leader以保证集群的正常运行。</div>
          </div>
          <div class="card-source">来源: 2. Follower（跟随者）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
